package com.lwm.killer.controller;

import com.lwm.killer.domain.User;
import com.lwm.killer.redis.RedisService;
import com.lwm.killer.redis.prefix.UserTokenKey;
import com.lwm.killer.service.UserService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.CookieValue;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletResponse;


@Controller
@RequestMapping("/goods")
public class GoodsController {

	@Autowired
	UserService userService;
	
	@Autowired
	RedisService redisService;
	
    @RequestMapping("/to_list")
	public String list(HttpServletResponse response, Model model,User user) {
//    public String list(HttpServletResponse response, Model model,
//					   @CookieValue(value = UserService.COOKI_NAME_TOKEN,required = false) String cookieToken,
//					   @RequestParam(value = UserService.COOKI_NAME_TOKEN,required = false) String paramToken) {
//    	if(StringUtils.isEmpty(cookieToken)&&StringUtils.isEmpty(paramToken)){
//    		return "login";
//		}
//		String token = StringUtils.isEmpty(paramToken)?cookieToken:paramToken;
//    	User  user = userService.getByToken(response,token);
    	model.addAttribute("user", user);
        return "goods_list";
    }
    
}
